
<?php $this->headScript()->appendFile($this->publicUrl . "/Scripts/jquery.js"); ?>
<?php $this->headScript()->appendFile($this->publicUrl . "Scripts/formsValidation.js"); ?>
<?php $this->headScript()->appendFile($this->publicUrl . "Scripts/loadProductTexts.js"); ?>
<?php $this->headScript()->captureStart(); ?>
setupLoadProductTexts("<?= $this->url(array("controller"=>"Products","action"=>"product-Texts-Ajax")); ?>");

function validateTextsForm() {
	var validator = new FormValidator('product_texts');	
	validator.isNotEmpty('name', '<?= $this->translate('isEmpty') ?>');
	validator.isNotEmpty('description', '<?= $this->translate('isEmpty') ?>');
	return validator.result;
}

function validateProductForm() {
	var validator = new FormValidator('product');	
	validator.isNotEmpty('price', '<?= $this->translate('isEmpty') ?>');
	validator.isRealNumber('price', "<?= $this->validationMessage('notFloat') ?>");
	return validator.result;
}

$(document).ready(function() {
	$(".show-me").show();
	$(".hide-me").hide();
});
<?php $this->headScript()->captureEnd(); ?>

<h2><?= $this->translate("EditOfProductNumber") ?> <?= $this->product_id ?></h2>

<fieldset>
	<legend><?= $this->fieldsets->translate("EditProduct") ?></legend>
	
	<?php $this->productForm->setAttrib('onsubmit', 'return validateProductForm();') ?>	
	<?= $this->productForm ?>
</fieldset>

<fieldset>
	<legend><?= $this->fieldsets->translate("EditTexts"); ?></legend>
	<select id="selectLanguage" class="show-me">
		<?php foreach ($this->languages as $language) { ?>
			<option value="<?= $language->getId(); ?>" 
				<?= $language->getId() == $this->textsForm->languageId->getValue() ? "selected='selected'" : ""; ?>
				>
				<?= $language->getLanguageName()."-".$language->getCultureName(); ?>
			</option>
		<?php } ?>
	</select> <span id="loading"></span>
	
	<ul class="hide-me">		
		<?php foreach ($this->languages as $language) { ?>
			<li>
				<?php $editUrl = 
					$this->url(array(
						"controller"=>"Products",
						"action"=>"edit-product", 
						'id' => $this->product_id,
						'selectLanguage' => $language->getId())); ?>
				<?php if ($language->getId() != $this->textsForm->languageId->getValue()) { ?>
				<a href="<?= $editUrl ?>">
				<?php } ?>
				
					<?= $language->getLanguageName()."-".$language->getCultureName(); ?>
					
				<?php if ($language->getId() != $this->textsForm->languageId->getValue()) { ?>
				</a>
				<?php } ?>
			</li>
		<?php } ?>
	</ul>
	
	<?php $this->textsForm->setAttrib('onsubmit', 'return validateTextsForm();') ?>
	<?= $this->textsForm; ?>
</fieldset>